home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Hacks / Hacks '96 / Internet Chooser / reggie / light / my mactcp.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-22  |  3.7 KB  |  124 lines  |  [TEXT/MMCC]

  1. /* File "mactcp.h", Light Sockets - Copyright (C) Matt Slot, 1996             */
  2. /* MacTCP implementation for "Light Sockets" network abstraction library.     */
  3.  
  4. #ifndef __MACTCP_HEADER__
  5. #define __MACTCP_HEADER__
  6.  
  7. #ifndef __STD_TYPES_HEADER__
  8. #include "stdtypes.h"
  9. #endif /* __STD_TYPES_HEADER__ */
  10.  
  11. #ifndef __NET_STACK_HEADER__
  12. #include "netstack.h"
  13. #endif /* __NET_STACK_HEADER__ */
  14.  
  15. #include <MacTCP.h>
  16.  
  17. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  18. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  19. /* Preprocessor Defines */
  20.  
  21. #define kMacTCPSocketBufferSize        4096
  22. #define kMacTCPDataBufferSize        1024
  23. #define kMacTCPNumParamBlocks          10
  24.  
  25. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  26. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  27. /* Enum/Structure/Class Definitions */
  28.  
  29. typedef struct MacTCPData {
  30.     union {
  31.             UDPiopb            udppb;
  32.             TCPiopb            tcppb;
  33.         } pb;
  34.             wdsEntry        wds[2];
  35.             UInt32            dataLen;
  36.             Byte8            dataBuff[kMacTCPDataBufferSize];
  37.     } MacTCPData, *MacTCPDataPtr;
  38.  
  39. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  40.  
  41. typedef class MacTCPStack : public NetworkStack {
  42.  
  43. public:
  44.  
  45.     /* Constructor/Destructor */
  46.                             MacTCPStack        (SocketRef socket);
  47.     virtual                    ~MacTCPStack    (void);
  48.  
  49.  
  50.     /* Network stack dispatch */
  51.     virtual SocketResult     DoLoad            (void);
  52.     virtual SocketResult     DoUnload        (void);
  53.     
  54.  
  55.     /* Socket-based dispatch */
  56.     virtual SocketResult     DoCreate        (void);
  57.     virtual SocketResult     DoTickle        (void);
  58.     virtual SocketResult     DoDispose        (void);
  59.  
  60.     virtual SocketResult     DoBind            (SocketAddressPtr reqAddress,
  61.                                                 SocketAddressPtr retAddress);
  62.     virtual SocketResult     DoUnbind        (void);
  63.     
  64.  
  65.     /* Name service dispatch */
  66.     virtual SocketResult     DoAddressResolve(Char8 *textAddress,
  67.                                                 SocketAddressPtr socketAddress);
  68.     virtual SocketResult     DoAddressLookup    (SocketAddressPtr socketAddress,
  69.                                                 Char8 *textAddress);
  70.  
  71.     /* Datagram-based dispatch */
  72.     virtual SocketResult     DoDatagramWrite    (Byte8 *dataPtr, UInt32 dataLen,
  73.                                                 SocketAddressPtr address);
  74.  
  75.     /* Stream-based dispatch */
  76.     virtual SocketResult     DoStreamServer    (UInt32 sessions);
  77.     virtual SocketResult     DoStreamClient    (SocketAddressPtr address);
  78.     virtual SocketResult     DoStreamWrite    (Byte8 *dataPtr, UInt32 dataLen);
  79.     virtual SocketResult     DoStreamClose    (Bool8 orderly);
  80.  
  81.  
  82. private:
  83.     
  84.     /* Private callbacks */
  85.     static pascal void        DNRComplete        (struct hostInfo *hInfo,
  86.                                                 Bool8 *doneFlag);
  87.     static void                E2SCleanup        (class MacTCPStack *stack);
  88.     static void                UDPAsyncRead    (struct UDPiopb *iopb);
  89.     static void                UDPAsyncBfrRtn    (struct UDPiopb *iopb);
  90.     static void                UDPSendComplete    (struct UDPiopb *iopb);
  91.     
  92.     static    UInt32            loadCount;        /* Class instance counter */
  93.             SInt16            refnum;            /* MacTCP driver refnum */
  94.             Bool8            disposing;        /* Indicates cleanup in progress */
  95.             StreamPtr        stream;            /* Underlying UDP/TCP stream */
  96.             UDPIOCompletionUPP readUPP;        
  97.             UDPIOCompletionUPP bfrRtnUPP;    
  98.             UDPIOCompletionUPP sendDoneUPP;        
  99.  
  100. #if GENERATINGCFM || __A5__
  101.             UInt32            homeA5;            /* Globals register */
  102. #else
  103.             UInt32            homeA4;            /* Globals register */
  104. #endif
  105.  
  106.             Byte8            buffer[kMacTCPSocketBufferSize];
  107.             MacTCPData        dataBuffs[kMacTCPNumParamBlocks];
  108.             UDPiopb            readPB;
  109.             QHdr            freeQ;
  110.             QHdr            busyQ;
  111.     } MacTCPStack, *MacTCPStackRef;
  112.  
  113. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  114. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  115. /* Function Prototypes */
  116.  
  117.  
  118. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  119. /* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
  120.  
  121.  
  122. #endif /* __MACTCP_HEADER__ */
  123.  
  124.